package pe.com.pgn.consolidadorventas.servidorestacion.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class SHA1 {
   
    public static String getHash(String message){
    	MessageDigest md;
        byte[] buffer, digest;
        String hash = "";
    	buffer = message.getBytes();
        try {
			md = MessageDigest.getInstance("SHA1");
			md.update(buffer);
		    digest = md.digest();

		    for(byte aux : digest) {
		            int b = aux & 0xff;
		            if (Integer.toHexString(b).length() == 1) hash += "0";
		            hash += Integer.toHexString(b);
		    }
		    
		} catch (NoSuchAlgorithmException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			hash = message;
		}

        return hash;
    }
}